import api from '../utils/api.js'
import user from './user.js'
export default {
	namespaced: true,
	state() {
		return {
			myOwnVouchers: [],
		}
	},
	mutations: {
		//保存当前用户代金券
		saveVouchers(state, vouchers) {
			state.myOwnVouchers = vouchers
		}
	},
	actions: {
		async getMyVoucher(context) {
			console.log('user',user.state)
			
			return await api
				.get(`user/${user}/voucher`)
				.then(vouchers => {
					context.commit('saveVouchers', vouchers)
				})
		}
	}
}
